package gui.tools;

import gui.ColorChooser;
import gui.LineSizeChooser;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

import tools.LineTool;

public class StraightLineToolSetup extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ColorChooser seletorCor = new ColorChooser();
	
	private LineSizeChooser seletorSize = new LineSizeChooser();
	
	private LineTool lineTool;
	
	public StraightLineToolSetup(LineTool tool){
		this.lineTool = tool;
		
		init();
	}

	protected void init(){
		
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		//Seletor cor
		seletorCor.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent e) {
				lineTool.setColor(seletorCor.getSelectedColor());
			}
		});
		
		seletorCor.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
		
		add(seletorCor);
		
		seletorSize.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				lineTool.setSize(seletorSize.getSelectedSize());
			}
		});
		
		seletorSize.setBorder( BorderFactory.createCompoundBorder(
				BorderFactory.createEtchedBorder(),
				BorderFactory.createEmptyBorder(10, 10, 10, 10)));
		
		add(seletorSize);
		
	}
	
}
